;
var user_edit_ops={
    init:function () {
        this.eventBind();
    },
    eventBind:function () {
        //div class方式 所以用.
        $(".user_edit_wrap .save").click(function () {
             //防止用户重复点击
            var btn_target = $(this);
            if(btn_target.hasClass("disabled")){
                common_ops.alert("正在处理，请不要重复提交");
                return;
            }

        //    获取我们要传递的变量
            var nickname_target =$(".user_edit_wrap input[name=nickname]");
            var nickname = nickname_target.val();

            var email_target =$(".user_edit_wrap input[name = email]");
            var email = email_target.val();

            if ( !nickname || nickname.length < 2){
                common_ops.tip("请输入复核规范的姓名",nickname_target);
                return false;
            }


            if ( !email || email.length < 2){
                common_ops.tip("请输入复核规范的邮箱",email_target);
                return false;
            }

            btn_target.addClass("disabled");

            var data ={
                nickname:nickname,
                email:email
            };

            $.ajax({
                url:common_ops.buildUrl("/user/edit"),
                type:'POST',
                data:data,
                dataType:'json',
                success:function (res) {

                    var callback =null;
                    if(res.code==200){
                        callback = function () {
                            //刷新当前页面
                            window.location.href=window.location.href;
                        }
                    }
                    common_ops.alert( res.msg,callback);
                }
            });

        });
    }
};

$(document).ready(function () {
   user_edit_ops.init();
});